<template>
    <div class="modal fade" id="delete_customer" tabindex="-1" role="dialog"
         aria-labelledby="delete_customer">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-body">
                    <div class="exit_box">
                        <div class="login-form">
                            <div class="exit_top">
                                <p class="text_1">您将删除客户？</p>
                                <p class="exit_top_text2">删除该客户信息将同步删除 ,该客户设备转移都本账户下</p>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-success" @click="confirm">确定</button>
                    <button type="button" class="btn btn-success export" data-dismiss="modal">取消
                    </button>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        props: {
            user: Object
        },
        methods: {
            confirm () {
                if (this.user.userId === undefined) {
                    return
                }
                this.$ajax
                    .userInfo
                    .deleteUser(this.user.userId)
                    .then((res) => {
                        let result = res.data
                        if (result.code === 200) {
                            this.$store.commit('showAlert', {success: this.$msgDictionary.deleteInfo.success})
                            this.$emit('refreshMenu')
                            let timer = setTimeout(function () {
                                clearTimeout(timer)
                                let time = setTimeout(function () {
                                    clearTimeout(time)
                                    $('#delete_customer').modal('hide')
                                }, 1000)
                                $('#msgModal').modal('hide')
                            }, 1000)
                        } else {
                            this.$store.commit('showAlert', {error: result.msg})
                        }
                    }, () => {
                        this.$store.commit('showAlert', {error: this.$msgDictionary.serviceException})
                    })
            }
        }
    }
</script>

<style scoped>
    .exit_box {
        position: relative;
        width: 100%;
        height: 100%;
        overflow: scroll;
        overflow-x: hidden;
        overflow-y: hidden;
        text-align: center;
    }

    .modal-body {
        color: white;
        background: #263238;
    }

    .modal-content {
        width: 428px;
        height: 280px;
    }

    .modal-body {
        height: 183px;
    }

    .text_1 {
        margin-top: 60px;
        font-size: 14px;
    }

    .exit_top_text2 {
        color: rgb(102, 102, 102);
        font-size: 12px;
    }

    .modal-footer{
        padding-top: 30px;
    }
</style>
